package com.thero.core.net;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * Created by wusk on 2017/11/28.
 * 初始化channel处理器列表
 */
public class ServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        // 字符串解码 和 编码
        pipeline.addLast("decoder", new StreamDecoder());
        pipeline.addLast("encoder", new StreamEncoder());

        // 自己的逻辑Handler
        pipeline.addLast("handler", new MessageHandler());
    }
}
